<template>
	<!-- 添加弹框 -->
	<el-dialog title="" width="60%" visible :show-close="false" :append-to-body="true" class="wrap" @close="cancel" :close-on-click-modal="false">
		<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
	    <div class="bt">消息订阅</div>
	    <el-form label-width="100px" class="form">
        <div class="wrap">
				<table>
					<tr v-if='this.lstype=="xz"'>
						<td>
							<div style="font-weight: bold;font-size:16px ;color: black;float: left;" >行政模块 </div>
		                    <!--<el-checkbox  v-model="xzqx" style="float: left;margin-left: 20px;" @change="checkall1()" >全选</el-checkbox>-->
						</td>
					</tr>
					<tr v-if='this.lstype=="xz"'>
						<td>

							<el-checkbox label="frmysbjallyn" v-model="qxbtn.c050x" class="check2"  style='margin-left: 30px;'>采购入库审核通知</el-checkbox>
							<el-checkbox label="frmysbjallyn" v-model="qxbtn.c051x" class="check2">采购退货审核通知</el-checkbox>
							<el-checkbox label="frmysbjallyn" v-model="qxbtn.c052x" class="check2">报损审核通知</el-checkbox>
							<el-checkbox label="frmysbjallyn" v-model="qxbtn.c053x" class="check2">盘点审核通知</el-checkbox>
							<el-checkbox label="frmysbjallyn" v-model="qxbtn.c054x" class="check2">教材学习用品库存预警通知</el-checkbox>
							<el-checkbox label="frmysbjallyn" v-model="qxbtn.c055x" class="check2">固定资产库存预警通知</el-checkbox>
							<el-checkbox label="frmysbjallyn" v-model="qxbtn.c056x" class="check2">办公用品库存预警通知</el-checkbox>
						</td>
					</tr>


					<tr v-if='this.lstype=="cw"'>
						<td >
							<div style="font-weight: bold;font-size:16px ;color: black;float: left;" >财务模块 </div>
		                    <!--<el-checkbox  v-model="cwqx" style="float: left;margin-left: 20px;" @change="checkall3()" >全选</el-checkbox>-->
						</td>
					</tr>
					<tr v-if='this.lstype=="cw"'>
						<td>
							<el-checkbox label="frmysbjaddyn" v-model="qxbtn.c057x" class="check2"  style='margin-left: 30px;'>缴费审核通知</el-checkbox>
							<el-checkbox label="frmysbjallyn" v-model="qxbtn.c058x" class="check2">退费审核通知</el-checkbox>
						</td>
					</tr>


				</table>
			</div>
			</el-form>
			<div class="an" style="text-align: center;margin-top: 20px;">
		<el-button type="primary" class="submit" @click="submit">保存</el-button>
		<el-button type="danger" class="submit" @click="cancel">退出</el-button>
		</div>
		
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
		data() {
			return {
				lstype:'',
				qxbtn: {
					c050x: false,
					c051x: false,
					c052x: false,
					c053x: false,
					c054x: false,
					c055x: false,
					c056x: false,
					c057x: false,
					c058x: false,
				},
				dialogTableVisible: true,
			}
		},
		created() {
			 this.search();
		},
		methods: {
			setqxstr(qxstr) {
				this.qxbtn.c050x = this.isexists(qxstr, "c050x");
				this.qxbtn.c051x = this.isexists(qxstr, "c051x");
				this.qxbtn.c052x = this.isexists(qxstr, "c052x");
				this.qxbtn.c053x = this.isexists(qxstr, "c053x");
				this.qxbtn.c054x = this.isexists(qxstr, "c054x");
				this.qxbtn.c055x = this.isexists(qxstr, "c055x");
				this.qxbtn.c056x = this.isexists(qxstr, "c056x");
				this.qxbtn.c057x = this.isexists(qxstr, "c057x");
				this.qxbtn.c058x = this.isexists(qxstr, "c058x");
			},
			isexists(str, tag) {
				try {
					if(str.indexOf(tag) != -1)
						return true;
					else
						return false;
				} catch(e) {
					return false;
				}
			},
			search () {

		    //查询搜索触发事件
            var logininfo = JSON.parse(localStorage.logininfo) ;
            var params3 = qs.stringify({
              yhid:logininfo.id,
              xxid:logininfo.xxid
              
			});
              this.searchLoading = true;
              this.axios.post(this.$store.state.api + 'ls/getxxdy',params3)
              .then( res => {
//                console.log(res,'wwwwwwwwwwwwwwwwww')
                  let data = res.data.data;
                  let list = data.list;
//                this.dataList = list;
                  this.setqxstr(list[0].xxdy);
//                this.setqxstr=res.data.data.list[0].xxdy;
                  this.lstype=res.data.data.list[0].lstype;
                  this.searchLoading = false;
              }).catch( res => {
                  this.searchLoading = false;
              })
          },
			submit() {
				var str = "";
				if(this.qxbtn.c050x) str += "c050x,";
				if(this.qxbtn.c051x) str += "c051x,";
				if(this.qxbtn.c052x) str += "c052x,";
				if(this.qxbtn.c053x) str += "c053x,";
				if(this.qxbtn.c054x) str += "c054x,";
				if(this.qxbtn.c055x) str += "c055x,";
				if(this.qxbtn.c056x) str += "c056x,";
				if(this.qxbtn.c057x) str += "c057x,";
				if(this.qxbtn.c058x) str += "c058x,";
				//检测
				this.$store.state.loading = true;
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					yhid: logininfo.id,
					xxid: logininfo.xxid,
					xxdy:str
				});
				//执行
				this.axios.post(this.$store.state.api + 'ls/updatexxdy', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'xxdy', cancel: false });
							this.$store.state.loading = false;
						} else {
						this.$message.warning(res.data.msg);
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						this.$store.state.loading = false;
					})
			},
			cancel() {
				this.$emit('close', { type: 'xxdy', cancel: true })
			},
		}
	}
</script>
<style lang="less" scoped >
	.wrap {
		.row{
			height:50px;
			line-height: 50px;
		}
		.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top: 0;
			left: 0;
			// margin-top: -70px;
			background: #50BFFF;
			// margin-left: -20px;
			// margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.close{
				z-index: 10;
				position: absolute;
		}
		.input-block {
			margin-bottom: 20px;
			text-align: center;
		}
		.input {
			width:280px;
			display: inline-block;
			margin-left: 10px;
		}
		.input1 {
			width: 210px;
			display: inline-block;
			margin-left: 10px;
		}
		.input-block span {
			display: inline-block;
			width: 70px;
			text-align: right;
		}
		.submit {
			width: 120px;
		}
		.wpfl {
			background: #fff;
			position: absolute;
			top: 5px;
			left: 5px;
		}
		.wpfl1 {
			width: 130%;
			background: #fff;
			position: absolute;
			top: 5px;
			left: -66px;
		}
		.form {
			text-align: left;
			margin-top: 20px;
			height: 80%;
			.select-block {
				width: 85%;
				display: block;
			}
			.select-block1 {
				width: 68%;
				// display: block;
			}
		}
	}
</style>
